package SmartFurniture;

import SmartFurniture.Factory.Huawei.HuaweiAirConditioner;
import SmartFurniture.Factory.Huawei.HuaweiDevice;
import SmartFurniture.Factory.Philips.PhilipsDevice;
import SmartFurniture.Factory.Xiaomi.XiaomiDevice;
import SmartFurniture.Interface.AbstractFactory;
import SmartFurniture.Interface.SmartDevice;
import SmartFurniture.Manager.DeviceManager;

import java.util.Scanner;

/*
enum Brand {
    XIAOMI, Huawei, Philips
}

enum DeviceType {
    LIGHT, AIR_CONDITIONER, Speaker
}
*/
//还是数字选择方便，不用枚举了

public class SmartFurnitureApplication {
    public static void main(String[] args) throws CloneNotSupportedException {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请选择品牌（1. 小米 2. 华为 3. 飞利浦）:");
        int brand = scanner.nextInt();

        AbstractFactory factory;
        switch (brand) {
            case 1:
                factory = new XiaomiDevice();
                break;
            case 2:
                factory = new HuaweiDevice();
                break;
            case 3:
                factory = new PhilipsDevice();
                break;
            default:
                System.out.println("输入错误，请重新输入！");
                return;
        }

        System.out.println("请选择设备类型（1. 灯 2. 空调 3. 音箱）:");
        int deviceType = scanner.nextInt();
        SmartDevice device;
        switch (deviceType) {
            case 1:
                device = factory.createLight();
                break;
            case 2:
                device = factory.createAirConditioner();
                break;
            case 3:
                device = factory.createSpeaker();
                break;
            default:
                System.out.println("输入错误，请重新输入！");
                return;
        }

        System.out.println("已创建设备! " + device.getInfo() );
        DeviceManager.getInstance().register(device);

        System.out.println("是否部署多个房间？（1. 是 2. 否）:");
        int isDeploy = scanner.nextInt();
        if (isDeploy == 1) {
            System.out.println("请输入房间数量:");
            int roomNum = scanner.nextInt();
            for (int i = 0; i < roomNum; i++) {
                SmartDevice cloneDevice = device.clone();

                System.out.println("设备克隆成功：Room" + (i+1) + " " + cloneDevice.getName());
            }
        } else if (isDeploy == 2) {
            System.out.println("设备已部署到当前房间");
        } else {
            System.out.println("输入错误，请重新输入！");
        }
    }
}
